package com.sunricher.telinkblemeshlib.db;

import androidx.room.*;

import com.sunricher.telinkblemeshlib.models.RoomScene;

import java.util.List;

@Dao
public interface RoomSceneDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long insert(RoomScene roomScene);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(List<RoomScene> roomScenes);

    @Query("SELECT * FROM room_scenes")
    List<RoomScene> selectAll();

    @Query("SELECT * FROM room_scenes WHERE roomId = :roomId")
    List<RoomScene> selectAllWithRoomId(int roomId);

    @Query("SELECT * FROM room_scenes WHERE roomId = :roomId AND identifier = :identifier")
    RoomScene select(int roomId, long identifier);

    @Update
    void update(RoomScene roomScene);

    @Update
    void update(List<RoomScene> roomScenes);

    @Query("DELETE FROM room_scenes WHERE identifier = :identifier")
    void deleteWithIdentifier(long identifier);

    @Query("DELETE FROM room_scenes WHERE roomId = :roomId")
    void deleteAllWithRoomId(int roomId);

    @Query("DELETE FROM room_scenes")
    void deleteAll();
}